package client.whiteboard.model;
import client.whiteboard.view.*;
import client.whiteboard.controller.*;
public class Whiteboard
{
	private ViewManager _viewManager;
	private GUIManager _guiManager;
	private DisplayManager _displayManager;
	private ViewController _viewController;
	private GUIController _guiController;
	private DisplayController _displayController;
	private View _view;
	private GUI _gui;
	private Display _display;
	private Drawing _drawing;
	private String _username;
	public Whiteboard(String username, ISubmitListener submitListener)
	{
		_username = username;
		_drawing = new Drawing();
		_viewManager = new ViewManager();
		_guiManager = new GUIManager(_username, submitListener);
		_guiManager.setDrawing(_drawing);
		_displayManager = new DisplayManager();
		_displayManager.setDrawing(_drawing);
		_displayManager.setAuthor(username);
		_guiController = new GUIController();
		_guiController.setManager(_guiManager);
		_viewController = new ViewController();
		_viewController.setManager(_viewManager);
		_view = new View();
		_gui = _view.getGUI();
		_guiController.setGui(_gui);
		_display = _view.getDisplay();
		_displayController = new DisplayController();
		_displayController.setManager(_displayManager);
		_displayController.setDisplay(_display);
		_display.setController(_displayController);
		_display.setDataInterface(_drawing);
		_displayManager.setDisplay(_display);
		_gui.setController(_displayController, _guiController);
		open();
	}
	public void loadData(String author, DrawingData drawingData)
	{
		_displayManager.setAuthor(author);
		_drawing.loadDrawingData(drawingData);
		_display.repaint();
	}
	public void open()
	{
		_view.setVisible(true);
		_view.toFront();
	}
}
